
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>SpringBoot的条件注解学习 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>SpringBoot的条件注解学习 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">SpringBoot中的条件注解主要解决了什么问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">条件注解是一种强大的机制，它能够根据特定条件（如环境、配置或其他因素）来动态地加载或配置Bean，从而使得应用程序更加灵活、智能，并实现高度可定制化的自动配置。</div>
          </div>
          <div class="card-source">来源: 基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring Boot条件注解的底层原理基于哪个核心接口？该接口的关键方法是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">所有条件注解都基于 `Condition` 接口实现。该接口中有一个关键的 `matches()` 方法，用于实现具体的条件判断逻辑，并返回一个布尔值来表示条件是否满足。</div>
          </div>
          <div class="card-source">来源: 条件注解的原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何实现一个自定义的条件逻辑以配合`@Conditional`注解使用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">要实现自定义条件，需要创建一个类并实现`Condition`接口，然后在其`matches`方法中定义具体的条件判断逻辑。该方法可以访问`ConditionContext`对象来获取运行时环境的信息。</div>
          </div>
          <div class="card-source">来源: @Conditional注解</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`@ConditionalOnProperty`注解的作用是什么？它如何与配置文件交互？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该注解的作用是当指定的配置属性存在且其值满足特定条件时，相应的配置或Bean才会生效。它直接读取配置文件（如`application.properties`）中的属性值来执行判断逻辑。</div>
          </div>
          <div class="card-source">来源: 条件注解与配置文件的关系</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在同一个配置类或Bean方法上使用多个条件注解时，它们之间的逻辑关系是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">多个条件注解之间的逻辑关系通常是“与”（AND）关系。这意味着所有条件注解的判断都必须同时满足，对应的Bean或配置类才会被加载到Spring容器中。</div>
          </div>
          <div class="card-source">来源: 条件注解的组合使用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`@ConditionalOnClass` 和 `@ConditionalOnMissingBean`这两个注解的触发条件分别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@ConditionalOnClass` 的触发条件是当类路径中存在指定的类时配置生效。`@ConditionalOnMissingBean` 的触发条件是当Spring容器中不存在指定的Bean时配置生效。</div>
          </div>
          <div class="card-source">来源: @Conditional的扩展注解</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring Boot在应用程序生命周期的哪个阶段执行条件注解的判断逻辑？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">条件注解的判断逻辑在Spring容器启动时进行。具体来说，在加载Bean的时候，会先判断这些Bean上的条件注解是否满足条件，只有满足条件的Bean才会被加载到容器中。</div>
          </div>
          <div class="card-source">来源: 条件注解的原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">条件注解可以被标注在哪些位置？在这两种位置上使用时分别有什么效果？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">条件注解可以标注在`@Bean`方法上或`@Configuration`类上。当标注在`@Bean`方法上时，控制该方法返回的Bean是否被创建；当标注在`@Configuration`类上时，控制整个配置类是否生效。</div>
          </div>
          <div class="card-source">来源: 基本概念</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`@ConditionalOnWebApplication` 和 `@ConditionalOnNotWebApplication` 注解分别适用于什么场景？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@ConditionalOnWebApplication` 用于当应用程序是一个Web应用时使配置生效的场景。相反，`@ConditionalOnNotWebApplication` 用于当应用程序不是一个Web应用时使配置生效的场景。</div>
          </div>
          <div class="card-source">来源: @Conditional的扩展注解</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
